package org.myself.meeting.service;


import org.myself.meeting.Utils.Constant;
import org.myself.meeting.mapper.AwardMapper;
import org.myself.meeting.mapper.DepartmentMapper;
import org.myself.meeting.model.Award;
import org.myself.meeting.model.AwardRecord;
import org.myself.meeting.model.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.text.resources.FormatData;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class AwardService {

    @Autowired
    DepartmentMapper departmentMapper;

    @Autowired
    AwardMapper awardMapper;

    public List<Award> getAward() {
        return awardMapper.getAward();
    }

    public Integer addAwardRecord(String awardname, Employee emp) {
        String departmentname = departmentMapper.getDepById(emp.getDepartmentid()).getDepartmentname();
        AwardRecord awardRecord =  new AwardRecord();
        awardRecord.setDepartmentname(departmentname);
        awardRecord.setEmployeename(emp.getEmployeename());
        awardRecord.setThetime(new Date());
        awardRecord.setAwardname(awardname);
        return awardMapper.addAwardRecord(awardRecord);
    }

    public List<AwardRecord> getAwardRecordAll() {
        List<AwardRecord> list = awardMapper.getAwardRecordAll();
        return list;
    }

    public List<AwardRecord> getAwardRecordStu(Integer awardstatusno) {
        List<AwardRecord> list = awardMapper.getAwardRecordStu(awardstatusno);
        return list;
    }

    //更新哦奖品记录的status
    public Integer updateAwardById(Integer id) {
        return awardMapper.updateAwardById(id, Constant.AWARDSTATUSYES);
    }

    public List<Award> getAwardAll() {
        return awardMapper.getAwardAll();
    }

    public Integer updateAwarding(Integer id, String name) {
        return awardMapper.updateAwarding(id,name);
    }
}
